package org.grow.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient
public class GatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }

//    fluxWeb
    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder routeLocatorBuilder){
//        http://localhost:9199/dbc/unixTime  Get =>http://localhost:9192/dbc/unixTime
//        http://localhost:9199/dbc/deal Post     =>http://localhost:9192/dbc/deal
//        http://localhost:9199/ssc/time Get  =>  http://localhost:9195/ssc/time
//        http://localhost:9199/ssc/exchangeScore Put  =>  http://localhost:9195/ssc/exchangeScore
//
       return routeLocatorBuilder.routes()
                .route("dbcRoute",(route)->
                        route.path("/dbc/**")
//                                .uri("http://localhost:9192")
                                .uri("lb://dealbill")
                )
                .route("sscRoute",route->
                        route.path("/ssc/**")
//                                 .uri("http://localhost:9195")
                                 .uri("lb://STUDENTSCORE")
                )
                .build();
    }

}
